<?php

namespace app\common\resourceHandle;

use think\Model;

class ShopGoodsResource extends ResourceHandle
{

    /**
     * @param Model $model
     * @return array
     * @throws \think\Exception
     */
    public function handle(Model $model): array
    {
        $model->hidden(['cost' , 'createtime' , 'updatetime']);
        $model->goods;
        $model->goodsSaleNum = count($model->orderGoods);
        unset($model->orderGoods);
        return $model->toArray();
    }

    public function info(Model $model): array
    {
        $model->shop = (new ShopResource())->handle($model->shop);
        return $this->handle($model);
    }

    public function lists(Model $model): array
    {
//        $model->hidden(['cost' , 'updatetime']);
//        $model->goods;
        return $model->toArray();
    }
}